<HTML>
<HEAD>
<TITLE>
BeanFactoryImpl.h
</TITLE>
</HEAD>
<BODY>
<PRE>
<font color="green">/*
* Copyright 2006 the original author or authors.
* 
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* 
*      http://www.apache.org/licenses/LICENSE-2.0
* 
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/</font>

<font color="blue">#ifndef</font> AUTUMN_BEANFACTORYIMPL_H
<font color="blue">#define</font> AUTUMN_BEANFACTORYIMPL_H

<font color="blue">#include</font> <font color="maroon">"IBeanFactory.h"</font>
<font color="blue">#include</font> <font color="maroon">"IResource.h"</font>
<font color="blue">#include</font> <font color="maroon">"AutumnConfig.h"</font>
<font color="blue">#include</font> <font color="maroon">"BeanManager.h"</font>
<font color="blue">#include</font> <font color="maroon">"TypeManager.h"</font>

<font color="blue">using</font> <font color="blue">namespace</font> std;

<font color="blue">namespace</font> Autumn<font color="black">{</font>

<font color="green">/** 
 * BeanFactory implementation
 *
 * @version 0.1.0
 * @since 2006-12-5
 */</font>

<font color="blue">class</font> BeanFactoryImpl<font color="black">:</font><font color="blue">public</font> IBeanFactory<font color="black">{</font>
<font color="blue">private</font><font color="black">:</font>
    <font color="green">/** 
     * Autumn configuration
     */</font>
    AutumnConfig<font color="black">*</font> Config;

    <font color="green">/** 
     * Autumn bean manager
     */</font>
    BeanManager<font color="black">*</font> ManagerOfBean;

    <font color="green">/** 
     * Autumn type manager
     */</font>
    TypeManager<font color="black">*</font> ManagerOfType;

<font color="blue">public</font><font color="black">:</font>
    <font color="green">/** 
     * Constructor
     * @param config Configuration resource
     */</font>
    BeanFactoryImpl<font color="black">(</font>IResource<font color="black">*</font> config<font color="black">)</font>;

    <font color="green">/** 
     * Get a bean with bean's name
     * @param name Bean's name
     * @param basename Bean's base class name
     * @return A pointer to the bean or to its base class
     */</font>
    virtual <font color="blue">void</font><font color="black">*</font> getBean<font color="black">(</font><font color="blue">const</font> string<font color="black">&</font> <font color="blue">name</font>, <font color="blue">const</font> string<font color="black">&</font> basename <font color="black">=</font> <font color="maroon">""</font><font color="black">)</font>;

    <font color="green">/** 
     * Free a bean
     * @param p A pointer to the bean
     */</font>
    virtual <font color="blue">void</font> freeBean<font color="black">(</font><font color="blue">void</font><font color="black">*</font> p<font color="black">)</font>;
    
    <font color="green">/** 
     * A bean exists or not
     * @param name Bean's name
     * @return True if it exists, or false.
     */</font>
    virtual <font color="blue">bool</font> containsBean<font color="black">(</font><font color="blue">const</font> string<font color="black">&</font> <font color="blue">name</font><font color="black">)</font> <font color="blue">const</font>;

    <font color="green">/** 
     * A bean is a singleton or not
     * @param name Bean's name
     * @return True if it's a singleton, or false.
     */</font>
    virtual <font color="blue">bool</font> isSingleton<font color="black">(</font><font color="blue">const</font> string<font color="black">&</font> <font color="blue">name</font><font color="black">)</font> <font color="blue">const</font>;

    <font color="green">/** Destructor */</font>
    virtual ~BeanFactoryImpl<font color="black">(</font><font color="black">)</font>;
<font color="black">}</font>;

<font color="black">}</font> <font color="green">// End namespace Autumn</font>
<font color="blue">#endif</font>

</PRE>
</BODY>
</HTML>
